﻿using System;
using System.Collections.Generic;
using System.Text;
using DevExpress.Xpo;
using Component;
namespace Component
{
    public class Cart_ProductDB:Base
    {
        /// <summary>
        /// public static XPCollection<Cart_Product> GetAll()
        /// </summary>
        /// <returns>XPCollection<Cart_Product></returns>
        public static XPCollection<Cart_Product> GetAll(bool admin)
        {
            XPCollection<Cart_Product> _xpCart_Product = new XPCollection<Cart_Product>(KetNoiCSDL.session);
            _xpCart_Product.Filter = FilterAll(admin);
            return _xpCart_Product;
        }
        /// <summary>
        /// public static Cart_Product GetObjectByid(int id)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static Cart_Product GetObjectByid(int id)
        {
            XPCollection<Cart_Product> _xpCart_Product = new XPCollection<Cart_Product>(KetNoiCSDL.session);
            _xpCart_Product.Filter = FilterById(id, true);
            if (_xpCart_Product.Count > 0)
            {
                return _xpCart_Product[0];
            }
            return null;
        }
        public static XPCollection<Cart_Product> CartDetail(int idCart, bool admin)
        {
            XPCollection<Cart_Product> _xpCart_Product = new XPCollection<Cart_Product>(KetNoiCSDL.session);
            _xpCart_Product.Filter = FilterParamTypeInt (ColumCart_Product._Cart,idCart,true);
            return _xpCart_Product;
        }
    }
}
